import { IPSSysBackService } from './ipssys-back-service';
import { IPSDataEntity } from '../dataentity/ipsdata-entity';
import { IPSDEAction } from '../dataentity/action/ipsdeaction';
import { IPSDEDataSet } from '../dataentity/ds/ipsdedata-set';
import { IPSSysSFPlugin } from '../res/ipssys-sfplugin';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSSysBackServiceImpl extends PSModelObjectImpl implements IPSSysBackService {
  get codeName(): string {
    return this.M.codeName;
  }

  get containerTag(): string {
    return this.M.containerTag;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdeaction: IPSDEAction | null = null;

  getPSDEAction(): IPSDEAction | null {
    if (this.psdeaction != null) return this.psdeaction;
    const value = this.M.getPSDEAction;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getPSDataEntity();
    if (ipsdataentity != null) {
      this.psdeaction = ipsdataentity.findPSDEAction(value);
    }
    return this.psdeaction;
  }

  get psDEAction(): IPSDEAction | null {
    return this.getPSDEAction();
  }

  getPSDEActionMust(): IPSDEAction {
    const value = this.getPSDEAction();
    if (value == null) {
      throw new Error('未指定调用实体行为');
    }
    return value;
  }

  protected psdedataset: IPSDEDataSet | null = null;

  getPSDEDataSet(): IPSDEDataSet | null {
    if (this.psdedataset != null) return this.psdedataset;
    const value = this.M.getPSDEDataSet;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getPSDataEntity();
    if (ipsdataentity != null) {
      this.psdedataset = ipsdataentity.findPSDEDataSet(value);
    }
    return this.psdedataset;
  }

  get psDEDataSet(): IPSDEDataSet | null {
    return this.getPSDEDataSet();
  }

  getPSDEDataSetMust(): IPSDEDataSet {
    const value = this.getPSDEDataSet();
    if (value == null) {
      throw new Error('未指定目标数据集');
    }
    return value;
  }

  protected psdataentity: IPSDataEntity | null = null;

  getPSDataEntity(): IPSDataEntity | null {
    if (this.psdataentity != null) return this.psdataentity;
    const value = this.M.getPSDataEntity;
    if (value == null) {
      return null;
    }
    this.psdataentity = this.getPSModel4('dataentity.IPSDataEntity', value, 'getPSDataEntity') as IPSDataEntity;
    return this.psdataentity;
  }

  get psDataEntity(): IPSDataEntity | null {
    return this.getPSDataEntity();
  }

  getPSDataEntityMust(): IPSDataEntity {
    const value = this.getPSDataEntity();
    if (value == null) {
      throw new Error('未指定实体对象');
    }
    return value;
  }

  protected pssyssfplugin: IPSSysSFPlugin | null = null;

  getPSSysSFPlugin(): IPSSysSFPlugin | null {
    if (this.pssyssfplugin != null) return this.pssyssfplugin;
    const value = this.M.getPSSysSFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyssfplugin = this.getPSModel4('res.IPSSysSFPlugin', value, 'getPSSysSFPlugin') as IPSSysSFPlugin;
    return this.pssyssfplugin;
  }

  get psSysSFPlugin(): IPSSysSFPlugin | null {
    return this.getPSSysSFPlugin();
  }

  getPSSysSFPluginMust(): IPSSysSFPlugin {
    const value = this.getPSSysSFPlugin();
    if (value == null) {
      throw new Error('未指定后台扩展插件');
    }
    return value;
  }

  get predefinedType(): 'DENOTIFY' | 'SYSDATASYNCAGENT' | 'WFCALLBACK' | 'SYSADMIN' | 'SYSDTSQUEUE' | 'USER' {
    return this.M.predefinedType;
  }

  get serviceContainer(): 'SC01' | 'SC02' | 'SC03' | 'SC04' | 'USER' {
    return this.M.serviceContainer;
  }

  get serviceHandler(): string {
    return this.M.serviceHandler;
  }

  get serviceOrder(): number {
    return this.M.serviceOrder;
  }

  get serviceParams(): string {
    return this.M.serviceParams;
  }

  get servicePolicy(): string {
    return this.M.servicePolicy;
  }

  get servicePolicy2(): string {
    return this.M.servicePolicy2;
  }

  get serviceTag(): string {
    return this.M.serviceTag;
  }

  get serviceTag2(): string {
    return this.M.serviceTag2;
  }

  get startMode(): 'AUTO' | 'MANUAL' {
    return this.M.startMode;
  }

  get taskType(): 'PREDEFINED' | 'DEACTION' | 'USER' {
    return this.M.taskType;
  }

  get timerPolicy(): string {
    return this.M.timerPolicy;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get timerMode(): boolean {
    return this.M.timerMode != null ? this.M.timerMode : false;
  }

  get cls(): string {
    return 'PSSysBackServiceImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'backservice.IPSSysBackService') return true;
    return super.instanceof(cls);
  }
}
